Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(fix): allow Result tuple to be [undefined, undefined] #174

Merged
merged 5 commits into from
Aug 16, 2024

Conversation

aleclarson
Copy link
Member

@aleclarson aleclarson commented Aug 16, 2024

Tip

The owner of this PR can publish a preview release by commenting /publish in this PR. Afterwards, anyone can try it out by running pnpm add radashi@pr<PR_NUMBER>.

Summary

Fix isResult to return true for a [undefined, undefined] tuple. This is to handle the case where a function with a possibly undefined return value is wrapped with tryit, which may produce such a tuple.

I'm also constraining the TError type parameter of Result/Ok/Err so it must be a subtype of the built-in Error type. In other words, it no longer allows the error element to be any type. This is necessary to reduce the chance of isResult returning a false positive for certain arrays.

Note: This is a "chore" and not a "fix" because isResult hasn't been released yet.

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size 1 Difference (%)
M src/typed/isResult.ts 217 +102 (+89%)
M src/typed/isResultErr.ts 261 +102 (+64%)

Footnotes

  1. Function size includes the import dependencies of the function.

@aleclarson aleclarson merged commit ada3225 into main Aug 16, 2024
8 checks passed
@aleclarson aleclarson deleted the fix/isResult-check branch August 16, 2024 00:30
Copy link

A new beta version 12.2.0-beta.6b76988 has been published to NPM. 🚀

To install:

The radashi@beta tag also includes this PR.

See the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant